package com.htl.集合;

import java.util.*;

public class HashMap__test {
    public static void main(String[] args) {
        HashMap hashMap = new HashMap();
        hashMap.put("h", "Hello");
        hashMap.put("w", "World");
        hashMap.put("j", "Java");
        hashMap.put("s", "JavaSE");
        hashMap.put("m", "JavaME");
        hashMap.put("e", "JavaEE");
        hashMap.put("j", "Jack");
        System.out.println(hashMap);
        System.out.println("==========================================");
        // 1、迭代器
        Set set = hashMap.entrySet();
        Iterator<Map.Entry> iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry next = iterator.next();
            System.out.println(next.getKey()+"----"+next.getValue());
        }
        System.out.println("==========================================");
        // 2、获取key所在的set集合
        Set keySet = hashMap.keySet();
        Iterator iterator1 = keySet.iterator();
        while (iterator1.hasNext()) {
            System.out.println(iterator1.next());
        }
        System.out.println("==========================================");
        // 3、获取value所在的Collection集合
        Collection values = hashMap.values();
        Iterator iterator2 = values.iterator();
        while (iterator2.hasNext()) {
            System.out.println(iterator2.next());
        }

    }
}
